#include "drawingmac.h"

DrawingMac::DrawingMac()
{
    //添加各种参数到列表中
    initRootParasList();
    initRootHMIConfigurationList(m_allParasList);//超级用户界面配置
    initPatternsParasList();
    initSoftwareParasList(m_allParasList);
    initTimeParasList(m_allParasList);
    initMcParasList();
    initWkParasList();

    //初始化控制动作列表
    initOutCtrlList();

    //初始化快捷功能列表
    initShortCutList();

    //初始化辅助功能列表
    initAssistList();

    //初始化文件设置功能列表
    initFileSetList();

    //参数分类功能
    initParaSetList();

    //初始化传感器列表
    initSensorList();

    //初始化错误代码和状态列表
    initErrorCodeAndStateList();

    //初始化九宫格
    initNinebtn1234();

    //加载右上角信息
    initFileInfoLabel();
}

DrawingMac::~DrawingMac()
{

}

void DrawingMac::initNinebtn1234()
{
    m_nineBtn.insert(1,NineItem(FUN_ALLTOZERO,"buttonAllToZero"));//全部归零
    m_nineBtn.insert(2,NineItem(FUN_FLAT_SETANCHORPOINT,"buttonSetEmbPoint"));//定定位点
    m_nineBtn.insert(3,NineItem(FUN_PROCESSRESET,"buttonProcessReset"));//流程复位
    m_nineBtn.insert(4,NineItem(FUN_SIMULATED_STATUS,"buttonSimulatedStatus"));// 模拟工作状态
}

void DrawingMac::initFileInfoLabel()
{
    m_fileInfo.append(FileName);
    m_fileInfo.append(Index);
    m_fileInfo.append(BeginPoint);
    m_fileInfo.append(Range);
    m_fileInfo.append(Position);
    m_fileInfo.append(ZCoor);
    m_fileInfo.append(Production);
}

void DrawingMac::initPatternsParasList()
{

}

#define UNITDOT 2 //小数点位数 0.1mm或0.01mm
void DrawingMac::initMcParasList()
{
    QTextCodec *cod = QTextCodec::codecForLocale();

    // X向格子数,范围0-24
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SETTING,
                                        10, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Number of X-direction grids"),//X向格子数
                                        0, 0, 24, 0, 0, tr(""), tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    //Y向格子数,范围0-19
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SETTING,
                                        11, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Number of Y-direction grids"),//Y向格子数
                                        0, 0, 19, 0, 0, tr(""), tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // X向采集长度,单位mm,范围-5000-5000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_ACTION,
                                        12, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("X-direction acquisition length"),//X向采集长度
                                        0, -5000, 5000, 0, 0, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // Y向采集长度,单位mm,范围-5000-5000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_ACTION,
                                        13, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Y-direction acquisition length"),//Y向采集长度
                                        0, -5000, 5000, 0, 0, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // X向采集起始位置,单位mm,范围-5000-5000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        14, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Starting position of X-direction collection"),//X向采集起始位置
                                        0, -5000, 5000, 0, 0, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // Y向采集起始位置,单位mm,范围-5000-5000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        15, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Starting position of Y-direction collection"),//Y向采集起始位置
                                        0, -5000, 5000, 0, 0, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // X框传感器坐标,单位 0.1mm,范围-500000-500000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        20, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("X-box sensor coordinates"),//X框传感器坐标
                                        0, -500000, 500000, 0, UNITDOT, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // Y框传感器坐标,单位 0.1mm,范围-500000-500000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        21, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Y-box sensor coordinates"),//Y框传感器坐标
                                        0, -500000, 500000, 0, UNITDOT, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 升降传感器高度,单位0.01mm,范围-100-10000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        22, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("lifting sensor height"),//升降传感器高度
                                        0, -100, 10000, 0, 2, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 可移动区域(X-), 范围 -2147483648--2147483647，单位0.1mm
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        40, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Movable area (X -)"),//可移动区域(X-)
                                        0, S32_MIN, S32_MAX, 0, UNITDOT, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 可移动区域(X+), 范围 -2147483648--2147483647，单位0.1mm
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        41, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Movable area (X +)"),//可移动区域(X+)
                                        0, S32_MIN, S32_MAX, 0, UNITDOT, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 可移动区域(Y-), 范围 -2147483648--2147483647，单位0.1mm
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        42, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Movable area (Y-)"),//可移动区域(Y-)
                                        0, S32_MIN, S32_MAX, 0, UNITDOT, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 可移动区域(Y+), 范围 -2147483648--2147483647，单位0.1mm
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        43, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Movable area (Y+)"),//可移动区域(Y+)
                                        0, S32_MIN, S32_MAX, 0, UNITDOT, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // x可切割区域负边界(X-), 范围 -2147483648--2147483647，单位0.1mm
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        44, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Negative boundary of X cuttable region(X-)"),//x可切割区域负边界(X-)
                                        0, S32_MIN, S32_MAX, 0, UNITDOT, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // x可切割区域正边界(X+), 范围 -2147483648--2147483647，单位0.1mm
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        45, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Positive boundary of the X cutting region(X+)"),//x可切割区域正边界(X+)
                                        0, S32_MIN, S32_MAX, 0, UNITDOT, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // y可切割区域正边界(Y-), 范围 -2147483648--2147483647，单位0.1mm
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        46, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Negative boundary of Y cuttable region(Y-)"),//y可切割区域负边界(Y-)
                                        0, S32_MIN, S32_MAX, 0, UNITDOT, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // y可切割区域正边界(Y+), 范围 -2147483648--2147483647，单位0.1mm
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        47, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Positive boundary of the Y cutting region(Y+)"),//y可切割区域正边界(Y+)
                                        0, S32_MIN, S32_MAX, 0, UNITDOT, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 升降上限,单位0.01mm,范围-100-10000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        80, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("lifting upper limit"),//升降上限
                                        0, -100, 10000, 0, 2, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 升降下限,单位0.01mm,范围-100-10000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        81, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("lifting lower limit"),//升降下限
                                        0, -100, 10000, 0, 2, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 画笔加工抬起高度, 范围 -100--10000，单位0.01mm
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        82, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Brush processing lifting height"),//画笔加工抬起高度
                                        0, -100, 10000, 0, 2, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, root));

    // 画笔加工下降高度，范围 -100--10000，单位0.01mm
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        83, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Brush processing descent height"),//画笔加工下降高度
                                        0, -100, 10000, 0, 2, "mm", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 130
    // XY归零运行速度, 范围 1--100，单位mm/s，默认 100
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        130, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("XY zero running speed"),//XY归零运行速度
                                        100, 1, 150, 100, 0, "mm/s", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // XY空走运行速度, 范围 100--600,单位mm/s，默认 200
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        (MC_SORT_SETTING|MC_SORT_SPEED),
                                        131, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("XY idle running speed"),//XY空走运行速度
                                        200, 100, 600, 200, 0, "mm/s", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // xy手动移动速度1, 范围 10--50，单位mm/s，默认 10
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        132, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Xy manual movement speed 1"),//xy手动移动速度1
                                        10, 1, 100, 10, 0, "mm/s", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // xy手动移动速度2, 范围 50--200，单位mm/s，默认 100
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        133, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Xy manual movement speed 2"),//xy手动移动速度2
                                        100, 50, 300, 100, 0, "mm/s", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // xy手动移动速度3, 范围 200--500，单位mm/s，默认 200
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        134, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Xy manual movement speed 3"),//xy手动移动速度3
                                        200, 200, 500, 200, 0, "mm/s", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 135
    // 升降归零速度,单位mm/s,范围1-50
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        135, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Zero speed of lifting and lowering"),//升降归零速度
                                        10, 1, 50, 10, 0, "mm/s", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 升降空走速度,范围 10-100, 单位mm/s，默认 50
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        136, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Lifting and descending speed"),//升降空走速度
                                        50, 10, 100, 50, 0, "mm/s", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 升降手动移动速度,范围 5--20，单位mm/s，默认 5
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        137, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Manual movement speed for lifting and lowering"),//升降手动移动速度
                                        5, 5, 20, 5, 0, "mm/s", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 最小速度变化限制 默认10 范围1-20
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        138, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Minimum speed change limit"),//最小速度变化限制
                                        10, 1, 20, 10, 0, "", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    //XY行走加速度，范围1--10000，单位mm/s2， 默认
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        139, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("XY walking acceleration"),//XY行走加速度
                                        100, 1, 10000, 100, 0, "mm/s2", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    //XY刹车加速度1--10000， 单位mm/s2，默认
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        140, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("XY brake acceleration"),//XY刹车加速度
                                        100, 1, 10000, 100, 0, "mm/s2", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    //150
    // 画笔最小绘画速度, 范围 1--100，单位mm/s，默认 10
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        150, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("The minimum drawing speed of the brush"),//画笔最小绘画速度
                                        10, 1, 100, 10, 0, "mm/s", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 画笔最大绘画速度, 范围 1--1500，单位mm/s，默认 1000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        (MC_SORT_SETTING|MC_SORT_SPEED),
                                        151, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Maximum painting speed of the brush"),//画笔最大绘画速度
                                        600, 1, 1500, 600, 0, "mm/s", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 画笔绘画加速度, 范围 1--5000，单位mm/s2，默认 500
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_SPEED,
                                        152, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Brush painting acceleration"),//画笔绘画加速度
                                        500, 1, 5000, 500, 0, "mm/s2", tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    // 画笔降速最小偏差角度，范围 0--18000，单位 0.01度，默认 3000
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_MACH,
                                        MC_SORT_POSITION,
                                        153, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("The minimum deviation angle for paintbrush deceleration"),//画笔降速最小偏差角度
                                        3000, 0, 18000, 3000, 2, cod->toUnicode("°"), tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

}

void DrawingMac::initWkParasList()
{
    //QTextCodec *cod = QTextCodec::codecForLocale();

    //产量预设, 范围0-S32_MAX，默认0
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_WORK,
                                        MC_SORT_SETTING,
                                        80, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Production preset"),//产量预设
                                        0, 0, S32_MAX, 0, 0, tr(""), tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    //完成后停车位置选择, 范围0-2，默认0
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_WORK,
                                        MC_SORT_ACTION,
                                        81, 0, 0, PARA_VALUE_TYPE_LIST,
                                        tr("Stop position selection after work complete"),//完成后停车位置选择
                                        0, 0, 2, 0, 0, tr(""), tr(""),
                                        //当前位置:0;起始点:1;偏移点:2
                                        tr("Current:0;Start:1;Offset:2"),
                                        0, 0, 0x0001, operate));

    // 开机动作 //bit 0 电机归零
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_WORK,
                                        MC_SORT_SETTING,
                                        101, 1, 0, PARA_VALUE_TYPE_LIST,
                                        tr("Startup motor to zero"),// 开机电机归零
                                        0, 0, 1, 0, 0, tr(""), tr(""),
                                        tr("Not allow:0;Allowed:1"), 0, 0, 0x0001, operate));

    //偏移点坐标X, 范围：最小-最大，默认0
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_WORK,
                                        MC_SORT_POSITION,
                                        102, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Offset point coordinate X"),//偏移点坐标X
                                        0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

    //偏移点坐标Y, 范围：最小-最大，默认0
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_WORK,
                                        MC_SORT_POSITION,
                                        103, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Offset point coordinate Y"),//偏移点坐标Y
                                        0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""),
                                        tr(""),
                                        0, 0, 0x0001, operate));

}

// 归零和手动移动和电机使能的 (控制参数1) 定义
#define    MT_LX                0x0001    // X向移动电机
#define    MT_LY                0x0002    // Y向移动电机
#define    MT_LUU                0x0003    // U电机
// 输出控制的 控制参数1 定义
#define OT_U_LIFT                0x0001    // U升降

#define KNIFE_COLLECT        0x0005 //刀压采集
#define KNIFE_U_TEST          0x0006 //刀压测试

void DrawingMac::initOutCtrlList()
{
    m_allOutCtrlList.clear();
    int showPriority = 1;
    m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("X to move motor"),MT_LX));// X向移动电机(归零,正转,反转)
    m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Y to move motor"),MT_LY));// Y向移动电机(归零,正转,反转)
    m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Lifting motor"),MT_LUU));// 升降电机(归零,正转,反转)
    m_allOutCtrlList.append(creatAscendingDescendingItem(0,showPriority++,tr("Lifting motor"),OT_U_LIFT));// 升降电机(升降)
    m_allOutCtrlList.append(makeAOutCtrlItem(0,showPriority++,tr("Pen pressure collection"),KNIFE_COLLECT,//笔压采集
                                             "",false,-1,-1,-1,
                                             "",false,-1,-1,-1,
                                             "",false,-1,-1,-1,
                                             "",false,-1,-1,-1,
                                             runStr,true,MANUALACTION_RUN,-1,-1));

    m_allOutCtrlList.append(makeAOutCtrlItem(0,showPriority++,tr("Pen pressure test"),KNIFE_U_TEST,//笔压测试
                                             "",false,-1,-1,-1,
                                             "",false,-1,-1,-1,
                                             "",false,-1,-1,-1,
                                             "",false,-1,-1,-1,
                                             runStr,true,MANUALACTION_RUN,-1,-1));

}

void DrawingMac::initShortCutList()
{
    m_allShortCutList.clear();
    int index = 1;
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("ProcessReset"),"buttonProcessReset",FUN_PROCESSRESET));//流程复位
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("All_Zero"),"buttonAllToZero",FUN_ALLTOZERO));// 全部归零
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("SetPositioning"),"buttonSetEmbPoint",FUN_FLAT_SETANCHORPOINT));//定定位点
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("backStartPoint"),"buttonBackEmbPoint",FUN_BACKSTARTPOINT));// 回起始点
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("backOffsetPoint"),"buttonBackOffsetPoint",FUN_BACKOFFSETPOINT));// 回偏移点
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("SetOffsetPoint"),"buttonSetAnchorPoint",FUN_SETOFFSETPOINT));// 定偏移点
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Front_Back"),"buttonForwardOrBack",FUN_FORWARDORBACK));// 快进快退
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Border"),"buttonSimulateFrame",FUN_SIMULATEFRAME));//空走边框
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("backworkPoint"),"buttonBackOffsetPoint",FUN_BACKWORKPOINT));// 回工作点
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Speed Select"),"buttonSpeedParas",FUN_SPD_SELECT));//速度选择
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("OutputReset"),"buttonFrameZero",FUN_OUTPUTRESET));//产量清零
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Pen pressure test"),"KnifePressure",FUN_KNIFE_TEST));//笔压测试   
}

void DrawingMac::initAssistList()
{
    m_allAssistList.clear();

    m_allAssistList.append(makeAAssistItem(0,0x0001,tr("Signal"),"buttonSensor",ASSIST_SENSOR));//传感器信号
    m_allAssistList.append(makeAAssistItem(0,0x0002,tr("Action"),"buttonControlAction",ASSIST_CONTROLACTION));//控制动作
    m_allAssistList.append(makeAAssistItem(0,0x0003,tr("HMIUpgrade"),"buttonHMIUpgrade",ASSIST_HMIUPGRADE));//界面升级
    m_allAssistList.append(makeAAssistItem(0,0x0004,tr("MCUpgrade"),"buttonMCUpgrade",ASSIST_MCUPGRADE));//主控升级
    m_allAssistList.append(makeAAssistItem(0,0x0006,tr("ParaImport"),"buttonParaImport",ASSIST_PARAIMPORT));//参数导入
    m_allAssistList.append(makeAAssistItem(0,0x0007,tr("ParaExport"),"buttonParaExport",ASSIST_PARAEXPORT));//参数导出
    m_allAssistList.append(makeAAssistItem(0,0x0008,tr("SoftwareSet"),"buttonSoftwareSet",ASSIST_SOFTWARESET));//软件设置
    m_allAssistList.append(makeAAssistItem(0,0x000A,tr("Network"),"buttonNetworkManage",ASSIST_NETWORK));//网络管理
    m_allAssistList.append(makeAAssistItem(0,0x000C,tr("Time"),"buttonTimeSet",ASSIST_TIMESET));//时间设置
    m_allAssistList.append(makeAAssistItem(0,0x000F,tr("Version"),"buttonVersionInfo",ASSIST_MCVERSION));//版本信息
    m_allAssistList.append(makeAAssistItem(0,0x0014,tr("Root"),"buttonRoot",ASSIST_ROOT));//超级用户

}

void DrawingMac::initFileSetList()
{
    m_allPatternSetList.clear();
    m_allPatternSetList.append(makeAPatternSetItem(0,0x0001,tr("Select"),"buttonPatternSelect",PATTERNSET_PATTERNSELECT));//文件选择
    m_allPatternSetList.append(makeAPatternSetItem(0,0x0004,tr("Import"),"buttonPatternImport",PATTERNSET_PATTERNIMPORT));//文件导入
    m_allPatternSetList.append(makeAPatternSetItem(0,0x0005,tr("Export"),"buttonPatternExport",PATTERNSET_PATTERNEXPORT));//文件导出
    m_allPatternSetList.append(makeAPatternSetItem(0,0x0006,tr("Delete"),"buttonPatternDelete",PATTERNSET_PATTERNDELETE));//文件删除
}

void DrawingMac::initParaSetList()
{
    m_allParaSetList.clear();
}

#define	DSS_BIT1		0x01	// idx1
#define	DSS_BIT2		0x02	// idx2
#define	DSS_BIT3		0x04	// idx3
#define	DSS_BIT4		0x08	// idx4
#define	DSS_BIT5		0x10	// idx5
#define	DSS_BIT6		0x20	// idx6
#define	DSS_BIT7		0x40	// idx7
#define	DSS_BIT8		0x80	// idx8

#define	DSS1_B_START_BT		0x0000	// 启动按钮(1~8)
#define	DSS1_B_PAUSE_BT		0x0001	// 暂停按钮(1~8)
#define	DSS1_B_READY_BT		0x0005	// 就绪按钮(1~8)
#define	DSS2_F1_X		DSS_BIT1	// X  (主框架X)
#define	DSS2_F1_Y		DSS_BIT2	// Y  (主框架Y)
#define	DSS2_F1_ZERO_POS	0x0020	// 框架(轴)1 零位
#define	DSS2_UD_CU1_POS		0x0048	// 裁切机头 高位(1~8)
#define	DSS1_B_AIR_TEST		0x0007	// 气压检测(1~8)
#define	DSS_HEAD_01		DSS_BIT1	// idx1
#define	DSS_HEAD_02		DSS_BIT2	// idx2
#define	DSS_HEAD_03		DSS_BIT3	// idx3
#define	DSS_HEAD_04		DSS_BIT4	// idx4
#define	DSS_HEAD_05		DSS_BIT5	// idx5
#define	DSS_HEAD_06		DSS_BIT6	// idx6
#define	DSS_HEAD_07		DSS_BIT7	// idx7
#define	DSS_HEAD_08		DSS_BIT8	// idx8
#define	DSS1_B_SAFE_TEST	0x0008	// 安全输入(1~8)

// J1
//#define IsStartButton			GetInput1Status	// 启动按钮
//#define IsStopButton			GetInput2Status	// 停止按钮
//#define IsStartButton2			GetInput3Status	// 启动按钮2(双手启动)
//#define	IsResetButton			GetInput4Status	// 复位按钮

#define	N1_INPUT1_IDX		DSS1_B_START_BT		// 启动按钮
#define	N1_INPUT1_BIT		DSS_BIT1
#define	N1_INPUT2_IDX		DSS1_B_PAUSE_BT		// 暂停按钮
#define	N1_INPUT2_BIT		DSS_BIT1
#define	N1_INPUT3_IDX		DSS1_B_START_BT		// 启动按钮
#define	N1_INPUT3_BIT		DSS_BIT2
#define	N1_INPUT4_IDX		DSS1_B_READY_BT		// 复位按钮
#define	N1_INPUT4_BIT		DSS_BIT1

// J2
//#define IsXZeroPos			GetInput7Status		// X零位

#define	N1_INPUT7_IDX		DSS2_F1_ZERO_POS	// 框架(轴)1 零位
#define	N1_INPUT7_BIT		DSS2_F1_X

// J3
//#define IsAirPressureOk			GetInput10Status		// 气压保护检测
#define	N1_INPUT10_IDX		DSS1_B_AIR_TEST		// 气压检测
#define	N1_INPUT10_BIT		DSS_BIT1

//#define IsYZeroPos			GetInput11Status		// Y零位

#define	N1_INPUT11_IDX		DSS2_F1_ZERO_POS	// 框架(轴)1 零位
#define	N1_INPUT11_BIT		DSS2_F1_Y

void DrawingMac::initSensorList()
{
    QList <SensorItem> sensorList;
    sensorList.append(makeASensorItem(DSS1_B_START_BT, 0, tr("Start button")));//启动按钮
    sensorList.append(makeASensorItem(DSS1_B_PAUSE_BT, 0, tr("Pause button")));//暂停按钮
    sensorList.append(makeASensorItem(DSS2_F1_ZERO_POS, 0, tr("X zero position")));//X零位
    sensorList.append(makeASensorItem(DSS2_F1_ZERO_POS, 1, tr("Y zero position")));//Y零位
    sensorList.append(makeASensorItem(DSS2_UD_CU1_POS, 0, tr("U zero position")));//U零位

    //将机型所需的传感器列表替换到传感器整体列表中
    for(int i = 0; i < sensorList.size(); i++)
    {
        int byteaddr = sensorList[i].m_byte_offset;
        int bitaddr = sensorList[i].m_bit_offset;
        QString str = sensorList[i].m_name;
        int type = sensorList[i].m_type;

        int idx = byteaddr*8+bitaddr;
        if(idx < m_allSensorList.size())
        {
            m_allSensorList[idx].m_name = str;
            m_allSensorList[idx].m_type = type;
        }
    }
}

void DrawingMac::initErrorCodeAndStateList()
{
    m_allErrorCodeAndStateList.clear();
    m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_LIFT_OUT_RANGE,tr("Head lifting position out of range")));               // 机头升降位置越界
}
